﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing.Design;

namespace mitasoft.ERS.Web.controls
{

    public enum ImageTypeEnum
    {
        OpenIssue,
        ClosedIssue,
        SubmitIssue
    }

    public partial class MainPageOption : System.Web.UI.UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            string ctrl =
            @"<table id='{0}' style='width: 200px'>
                <tr>
                    <td rowspan='3'>
                        <img alt='poza' src='{1}' />
                    </td>
                </tr>
                <tr>
                    <td ><b>{2}</b></td>
                </tr>
                <tr>
                    <td valign='top'>{3}</td>
                </tr>
            </table>";

            switch (IssueType)
            {
                case ImageTypeEnum.OpenIssue:
                    writer.Write(ctrl, this.ClientID, "images/bug_64.png", this.Title, this.Description);
                    break;
                case ImageTypeEnum.ClosedIssue:
                    writer.Write(ctrl, this.ClientID, "images/OKShield-64.png", this.Title, this.Description);
                    break;
                case ImageTypeEnum.SubmitIssue:
                    writer.Write(ctrl, this.ClientID, "images/Error-64.png", this.Title, this.Description);
                    break;
            }
        }

        //[Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
        //[UrlProperty]
        //[Browsable(true)]
        //[Bindable(true)]
        //[DefaultValue("")]
        //public string ImageURL { get; set; }

        [Browsable(true)]
        public ImageTypeEnum IssueType { get; set; }

        [Browsable(true)]
        public string Title { get; set; }

        [Browsable(true)]
        public string Description { get; set; }
    }
}